package ThreadDemo;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(() -> {
           while (true) {}
        });
        thread1.start();
        Thread thread2 = new Thread(() -> {
            try {
                thread1.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread2.start();
        for (int i = 0; i < 100; i++) {
            System.out.println(thread2.getState());
        }
    }
}
